package Exam;

/**
 * @author げっしょく
 * @date 2021/7/26
 */
public class
Student  implements Comparable<Student>{
    private String name;
    private int scor;
    private int age;

    public Student() {
    }

    public Student(String name, int scor, int age) {
        this.name = name;
        this.scor = scor;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getScor() {
        return scor;
    }

    public void setScor(int scor) {
        this.scor = scor;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", scor=" + scor +
                ", age=" + age +
                '}';
    }

    @Override
    public int compareTo(Student o) {
        int result = this.scor - o.scor;
        result = result == 0 ? this.age - o.age : result;
        result = result == 0 ? this.name.compareTo(o.name) : result;
        return result;
    }
}
